# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php8-pecl-msgpack
_extname=msgpack
pkgver=2.2.0_rc1
_pkgver=${pkgver/_rc/RC}
pkgrel=0
pkgdesc="PHP 8 extension provides API for communicating with MessagePack serialization - PECL"
url="https://pecl.php.net/package/msgpack"
arch="all"
license="BSD-3-Clause"
depends="php8-session php8-sockets"
makedepends="php8-dev"
source="php-pecl-$_extname-$_pkgver.tgz::https://pecl.php.net/get/$_extname-$_pkgver.tgz"
builddir="$srcdir"/$_extname-$_pkgver
provides="php-msgpack=$pkgver-r$pkgrel" # for backward compatibility
replaces="php-msgpack" # for backward compatibility

build() {
	phpize8
	./configure --prefix=/usr --with-php-config=php-config8
	make
}

check() {
	rm -f tests/034.phpt # XFAIL https://github.com/msgpack/msgpack-php/issues/136
	rm -f tests/035.phpt # fails on ppc64le as of slow environment https://github.com/msgpack/msgpack-php/issues/123
	# Tests require session and sockets extensions which are not bundled
	local _depsdir=/usr/lib/php8/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test PHP_TEST_SHARED_EXTENSIONS="
		-d extension=$_depsdir/session.so \
		-d extension=$_depsdir/sockets.so \
		-d extension=modules/$_extname.so" TESTS=--show-diff
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/php8/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/50_$_extname.ini
}

sha512sums="
4ddb9b6e9f4d9255d49c10e03a9ad4b37cf869f30b5e3c333518314bdbdfa8d4d20996a24954da19cba6352e76e02488b813fe6aa107c8fe390d6ca85d625096  php-pecl-msgpack-2.2.0RC1.tgz
"
